#ifndef H_GRAPHICS
#define H_GRAPHICS

#include <windows.h>
#include "stdint.h"
#include "geometry.h"

#define WINDOW_W (1024)
#define WINDOW_H (512)

struct Graphics;

Graphics *
GR_Instance(void);

HRESULT
GR_Init(Graphics *self, HWND hWnd, const WH &clientWH);

void
GR_Term(Graphics *self);

HRESULT
GR_Render(Graphics *self);

/** @return textureId */
int
GR_CreateTextureFromFile(
    Graphics *self,
    const wchar_t *textureFileName);

int
GR_CreateTextureFromFileS(
    Graphics *self,
    const char *textureFileName);

void
GR_ReleaseTexture(
    Graphics *self,
    int textureId);

/** @return modelId
 */
int
GR_RegisterModel(Graphics *self, int textureId, const WH &wh, const XY &uvXY, const WH &uvWH);

int
GR_RegisterModelS(
    Graphics *self,
    int textureId,
    float width,
    float height,
    float uvX,
    float uvY,
    float uvW,
    float uvH);

void
GR_UnregisterModel(Graphics *self, int modelId);

/**
 * @param XY sprite leftBottom position (pos.y is up vector)
 */
void
GR_PutSprite(Graphics *self, int modelId, const XY &pos, float z, uint32_t color);

/**
 * @param posX sprite left position (x is right vector)
 * @param posY sprite bottom position (y is up vector)
 */
void
GR_PutSpriteS(
    Graphics *self,
    int modelId,
    float posX,
    float posY,
    float z,
    uint32_t color);

void
GR_DrawLine(Graphics *self, const XY &pos0, const XY &pos1, float z, uint32_t color0, uint32_t color1);

void
GR_DrawLineS(Graphics *self, float pos0X, float pos0Y, float pos1X, float pos1Y, float z, uint32_t color0, uint32_t color1);

void
GR_DrawRect(Graphics *self, const XY &pos, const WH &wh, float z, uint32_t color);

#endif /* H_GRAPHICS */
